home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
351-375
/
disk_374
/
mat
/
ref
< prev
next >
Wrap
Text File
|
1992-05-06
|
3KB
|
62 lines
.K STR,FILE1,FILE2,FILE3
.bra {
.ket }
;; REF -- Highlights references in text
;; using the fast string search mode of Mat.
;; Each line of the file being searched is first checked for the
;; presence of the string; if it is found, a pattern match and slice
;; is applied to separate out the string; a template then reassembles
;; the line with ANSI highlighting characters around the match.
;; A title line is output for each file in which a match is found.
;; For convenience, a termination line is also generated.
;; Output is to a temporary file, which is typed out in its entirety
;; at the end (and left available for later re-examination).
;; for convenience it is run as a lower-priority background task:
run ChangeTaskPri -5 +
Mat >T:Ref_list S {STR} P "#?^{STR}^#?" T "^0
^1
^2" nocase TAG "^B
^P...
" {FILE1} {FILE2} {FILE3} label "+ + + +^|... no refs found" +
type T:Ref_list
;; Mat command line arguments:
;; S {STR} -- fast string search for the supplied argument
;;
;; P "#?^{STR}^#?" -- IF the line contains the string, this
;; pattern with slice marks will be applied;
;; As a result, slice 0 will be everything
;; before the matched segment, the segment
;; itself is slice 1, and what follows is
;; slice 2.
;;
;; T "^0@[1;33m^1@[0;31m^2" -- reassemble output with this
;; template (ESC characters in the
;; original have here been replaced
;; with '@' for clarity).
;; The template itself has the following parts:
;; ^0 -- begin with the original start of line (slice 0)
;; @[1;33m -- ANSI highlighting code (color & bold)
;; ^1 -- slice 1 -- the matched string
;; @[0;31m -- ANSI normal-text code
;; ^2 -- slice 2 -- the rest of the line
;;
;; nocase -- ignore case in all matching
;;
;; TAG "^B@[3;1m^P...@[0m" -- add this header before each file
;; in which a match is found. The ANSI
;; strings are similar to those above
;; (italic + bold);
;; the markers are:
;; ^B -- "break" -- an extra newline to start.
;; ^P -- complete pathname of matched file.
;;
;; {FILE1} {FILE2} {FILE3} -- up to three file specs allowed
;;
;; label "+ + + +^|... no refs found" -- terminating line; the
;; part before the "^|"
;; separator will be output unless there
;; were no matches, in which case the
;; text following it will appear.